# Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved.
#
# Licensed under the BSD 3-Clause License (the "License"); you may not use this
# file except in compliance with the License. You may obtain a copy of the
# License at
#
# https://opensource.org/licenses/BSD-3-Clause
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

cc_library(
    name = "common",
    srcs = ["common.cc"],
    hdrs = ["common.h"],
    deps = [
        "//flare/base:logging",
        "//flare/base:string",
        "//flare/base/net:endpoint",
        "@com_github_jsoncpp//:jsoncpp",
    ],
)

cc_library(
    name = "monitoring_system",
    srcs = ["monitoring_system.cc"],
    hdrs = [
        "monitoring_system.h",
    ],
    visibility = ["//visibility:public"],
    deps = [
        ":event",
        "//flare/base:dependency_registry",
    ],
)

cc_library(
    name = "dispatcher",
    srcs = ["dispatcher.cc"],
    hdrs = ["dispatcher.h"],
    visibility = ["//flare/base:__pkg__"],
    deps = [
        ":monitoring_system",
        "//flare/base:chrono",
        "//flare/base:logging",
        "//flare/base:never_destroyed",
        "//flare/base:string",
        "//flare/base/internal:hash_map",
        "//flare/base/internal:time_keeper",
        "@com_github_gflags_gflags//:gflags",
    ],
)

cc_library(
    name = "event",
    srcs = ["event.cc"],
    hdrs = ["event.h"],
    visibility = ["//flare/base:__pkg__"],
    deps = [
        ":fwd",
        "//flare/base:likely",
        "//flare/base:logging",
        "//flare/base/experimental:flyweight",
        "//flare/base/internal:hash_map",
    ],
)

cc_library(
    name = "fwd",
    hdrs = ["fwd.h"],
    visibility = ["//flare/base:__pkg__"],
)

cc_library(
    name = "init",
    srcs = ["init.cc"],
    hdrs = ["init.h"],
    visibility = [
        "//flare:__pkg__",
        "//flare/base:__pkg__",
        "//flare/base/internal:__pkg__",
    ],
    deps = [
        ":dispatcher",
        ":monitoring_system",
        "//flare/base:dependency_registry",
        "//flare/base:function",
        "//flare/base:logging",
        "//flare/base:never_destroyed",
        "//flare/base:string",
        "//flare/base/internal:hash_map",
        "@com_github_gflags_gflags//:gflags",
        "@com_github_jbeder_yaml_cpp//:yaml-cpp",
    ],
)

# cc_test(
#   name = "integration_test",
#   srcs = ["integration_test.cc"],
#   deps = [
#     "//flare/base:down_cast",
#     "//flare/base:monitoring",
#     "//flare/base/monitoring:monitoring_system",
#     "//flare/init:override_flag",
#     "//flare/testing:main",
#     "@com_github_gflags_gflags//:gflags",
#     "@com_google_googletest//:gtest_main",
#   ],
#   data = [
#     "testdata/remap_sys2.yaml",
#     "testdata/remap_sys3.yaml",
#   ]
# )
